// NetFolder.h

#ifndef __NET_FOLDER_H
#define __NET_FOLDER_H

#include "Net.h"

#include "IFolder.h"

#include <atlbase.h>

#include <vector>
#include <memory>

namespace Common
{
namespace FileSystem
{
namespace Net {

struct CResourceEx: public CResource
{
  CString Name;
};

class ATL_NO_VTABLE CNetFolder:
  public IFolderFolder,
  public IFolderGetSystemIconIndex,
  public CComObjectRootEx<CComSingleThreadModel>
{
	std::shared_ptr<CResource> _netResource;
  //CResource *_netResourcePointer;

  std::vector<std::shared_ptr<CResourceEx> > _items;

  CComPtr<IFolderFolder> _parentFolder;
  CString _path;
public:
  
	BEGIN_COM_MAP(CNetFolder)
		COM_INTERFACE_ENTRY(IFolderFolder)
		COM_INTERFACE_ENTRY(IFolderGetSystemIconIndex)
	END_COM_MAP()



	DECLARE_PROTECT_FINAL_CONSTRUCT()

	HRESULT FinalConstruct()
	{
		return S_OK;
	}

	void FinalRelease()
	{

	}
  
  //INTERFACE FolderFolder
	STDMETHOD(LoadItems)() ;
	STDMETHOD(GetNumberOfItems)(UINT32 *numItems) ;
	STDMETHOD(GetProperty)(UINT32 itemIndex, PROPID propID, PROPVARIANT *value) ;
	STDMETHOD(BindToFolder)(UINT32 index, IFolderFolder **resultFolder) ;
	STDMETHOD(BindToFolder)(const wchar_t *name, IFolderFolder **resultFolder) ;
	STDMETHOD(BindToParentFolder)(IFolderFolder **resultFolder) ;
	STDMETHOD(GetNumberOfProperties)(UINT32 *numProperties) ;
	STDMETHOD(GetPropertyInfo)(UINT32 index, BSTR *name, PROPID *propID, VARTYPE *varType) ;
	STDMETHOD(GetFolderProperty)(PROPID propID, PROPVARIANT *value) ;

  STDMETHOD(GetSystemIconIndex)(UINT32 index, INT32 *iconIndex);

  CNetFolder()//: _netResourcePointer(0) 
  {}
  HRESULT Init(const CString &path);
  HRESULT Init(const std::shared_ptr<CResource> & netResource,
      IFolderFolder *parentFolder, const CString &path);
};

}
}
}

#endif
